﻿/*****************************************************
**Copyright(C), 2021-2022, Ciqtek Technology.
**Version:     2.0
**Author:      hujiarui
**Date:        2023/06/28
**Description: 测量工具定义类
*****************************************************/

#ifndef GRAPHICSDEF_H
#define GRAPHICSDEF_H

#include "../../ofuidll_global.h"

#include <QGraphicsItem>

namespace OfUI {

	/**
	 * @brief  自定义Item类型
	 */
	enum ItemType
	{
		NONE_TYPE = QGraphicsItem::UserType + 1,    ///< 无类型
		STRAIGHT_LINE,                              ///< 直线
		PARALLEL_LINE,                              ///< 平行线
		RECT,                                       ///< 矩形
		ELLIPSE,                                    ///< 内切椭圆
		INSCRIBED_CIRCLE,                           ///< 内切式圆
		TWO_POINT_CIRCLE,                           ///< 两点式圆
		THREE_POINT_CIRCLE,                         ///< 三点式圆
		ANGLE,                                      ///< 角度
		POINT,                                      ///< 点
		TEXT                                        ///< 文本
	};

	/**
	 * @brief  getAscZValue 获取自增Z值
	 * @return UI_EXPORT qreal
	 */
	OFUIDLL_EXPORT qreal getAscZValue();

	/**
	 * @brief  distanceFromPointToLine 计算点到直线的距离
	 * @param  point
	 * @param  line
	 * @return UI_EXPORT double
	 */
	OFUIDLL_EXPORT double distanceFromPointToLine(const QPointF& point, const QLineF& line);

	/**
	 * @brief  getPointVerticalToLine 获取点到直线的垂交线
	 * @param  point
	 * @param  line
	 * @return UI_EXPORT QPointF
	 */
	OFUIDLL_EXPORT QPointF getPointVerticalToLine(const QPointF& point, const QLineF& line);

	/**
	 * @brief  getStraightLineFromObliqueLine 斜线改成X/Y轴方向的直线，修改p2
	 * @param  line
	 * @return UI_EXPORT QLineF
	 */
	OFUIDLL_EXPORT QLineF getStraightLineFromObliqueLine(const QLineF& line);

	/**
	 * @brief  getSquareFromRect 矩形改成正方形，修改bottomRight
	 * @param  rect
	 * @return UI_EXPORT QRectF
	 */
	OFUIDLL_EXPORT QRectF getSquareFromRect(const QRectF& rect);

	/**
	 * @brief  gerCircle 三点坐标计算圆心与半径
	 * @param  vPoints
	 * @param  center
	 * @param  dRadius
	 * @return UI_EXPORT bool
	 */
	OFUIDLL_EXPORT bool getCircle(const QVector<QPointF>& vPoints, QPointF& center, double& dRadius);

}

#endif // GRAPHICSDEF_H
